/**
 * 生成任意单号,需要传入两个参数
 * 1.当前数据库内的做大单号
 * 2.生成单号的前缀(大写两个字母)
 * 例如:PL20200812001
 * */

 export const addAnyID=  (maxID,newID) => {
  var date = new Date();
  var sqlmm = maxID.substring(6, 8);
  var sqlmax = maxID.substring(10, 13);
  console.log("sqlmm:" + sqlmm);
  console.log("sqlmax:" + sqlmax);
  if (Number(sqlmm) == date.getMonth() + 1) {
    var pomax = String(Number(sqlmax) + 1);
  } else {
    var pomax = "1";
  }
  if (pomax.length === 1) {
    pomax = "00" + pomax;
  } else if (pomax.length === 2) {
    pomax = "0" + pomax;
  }
  if (date.getMonth() + 1 <= 9) {
    var mm = `0${date.getMonth() + 1}`;
  } else {
    var mm = `${date.getMonth() + 1}`;
  }
  if (date.getDate() < 10) {
    var dd = `0${date.getDate()}`;
  } else {
    var dd = `date.getDate()`;
  }
  return `${newID}${date.getFullYear()}${mm}${dd}${pomax}`;
}






console.log(addAnyID('PL20200812001','PI'));
